 // 根据时间戳获取年月日时分秒，且小于10的补充0前缀
 const getTimestamp = function (timestamp = new Date().getTime()) {
	let date = new Date(timestamp);
	let y = date.getFullYear();
	let M = date.getMonth() + 1;
	let d = date.getDate();
	let h = date.getHours();
	let m = date.getMinutes();
	let s = date.getSeconds();
	let w = date.getDay();
	M = M > 9 ? `${M}` : `0${M}`;
	d = d > 9 ? `${d}` : `0${d}`;
	h = h > 9 ? `${h}` : `0${h}`;
	m = m > 9 ? `${m}` : `0${m}`;
	s = s > 9 ? `${s}` : `0${s}`;
	w = 1 + w;
	
	return [y, M, d, h, m, s, w];
 }
 /**
	* 格式化年月日 yyyy年MM月dd日 星期几
	*/
const dateFormate = function (date, dateLocal, weekLocal) {
	let arr;
	if (typeof date === 'string') {
		arr = date.split('-');
	} else {
		arr = getTimestamp(date);
	}
	let str = '*';
	if (arr.length >= 3) {
		let [y, m, d] = arr;
		console.log(y, m, d);
		let w = new Date(y, m, d).getDay();
		// let weekLocal = this.i18n_clock.week.type2;
		let week = w == '0' ? weekLocal.w0 : w == '1' ? weekLocal.w1 : w == '2' ? weekLocal.w2 : w == '3' ? weekLocal.w3 : w == '4' ? weekLocal.w4 : w == '5' ? weekLocal.w5 : w == '6' ? weekLocal.w6 : '';
		// str = `${y}${this.i18n.year}${m * 1}${this.i18n.month}${d * 1}${this.i18n.day} ${week}`;
		str = `${y}${dateLocal.year}${m * 1}${dateLocal.month}${d * 1}${dateLocal.day} ${week}`;
	}
	return str;
}

/**
 * 根据时间戳获取不同时间格式
 * type:
 * 0: yyyy-MM-dd
 * 1: yyyy-MM-dd HH:mm:ss
 * 2: HH:mm
 * 3: yyyy/MM/dd HH:mm:ss
 */
const formateTimestamp = function (type = 0, timestamp = new Date().getTime()) {
	let [y, M, d, h, m, s] = getTimestamp(timestamp);
	let str = '';
	if (type === 0) {
		str = `${y}-${M}-${d}`;
	} else if (type === 1) {
		str = `${y}-${M}-${d} ${h}:${m}:${s}`;
	} else if (type === 2) {
		str = `${h}:${m}`;
	} else if (type === 3) {
		str = `${y}/${M}/${d} ${h}:${m}:${s}`;
	}
	return str;
}
export default {
	formateTimestamp,
	dateFormate
} 